package com.briup.mt.service.impl;

import com.briup.mt.bean.*;

import com.briup.mt.dao.BaseRolePrivilegeMapper;
import com.briup.mt.service.IBaseRolePrivilegeService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;


import javax.annotation.Resource;
import java.util.List;

/**
 * @version 1.0
 * @auther YJ
 * @date 2020/12/16 11:09
 */

@Service
public class BaseRolePrivilegeServiceImpl implements IBaseRolePrivilegeService {
    @Resource
    private BaseRolePrivilegeMapper baseRolePrivilegeMapper;
    @Override
    public List<BaseRolePrivilege> query(Long roleId) {
        BaseRolePrivilegeExample example=new BaseRolePrivilegeExample();
        if (!StringUtils.isEmpty(roleId)){
            example.createCriteria().andRoleIdEqualTo(roleId);
        }
        return baseRolePrivilegeMapper.selectByExample(example);
    }

    @Override
    public void saveOrUpdate(BaseRolePrivilege baseRolePrivilege) {
        if (baseRolePrivilege.getId() == null) {
            baseRolePrivilegeMapper.insert(baseRolePrivilege);
        }else{
            baseRolePrivilegeMapper.updateByPrimaryKey(baseRolePrivilege);
        }
    }

    @Override
    public void deleteById(long id) {
        baseRolePrivilegeMapper.deleteByPrimaryKey(id);
    }
}

